﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TMDT_Nhom1A.DTO;
using TMDT_Nhom1A.BUS;

namespace TMDT_Nhom1A.Customer
{
    public partial class ChiTietHoaDon : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string OrderDate = "";
                decimal TotalPrice = 0;
                if (Request.QueryString["Orderb2bid"] != null)
                {
                    List<ORDER_DETAIL> listorderonline = Customer_BUS.GetDetailBillPaiedBuyOnline(Request.QueryString["Orderb2bid"].ToString(), ref OrderDate);
                    lbdate.Text = OrderDate;
                    gvdetailbillbuyonline.DataSource = listorderonline;
                    gvdetailbillbuyonline.DataBind();
                    gvdetailbillbuyonline.Visible = true;
                    for (int i = 0; i < listorderonline.Count; i++)
                    {
                        TotalPrice += (decimal)listorderonline[i].Cost;
                    }

                }

                if (Request.QueryString["OrderCouponID"] != null)
                {
                    List<ORDER_COUPON_DETAIL> listorderbycompany = Customer_BUS.GetDetailBillPaiedBuyByCompany(Request.QueryString["OrderCouponID"].ToString(), ref OrderDate);
                    lbdate.Text = OrderDate;
                    gvdetailbillbuybycompany.DataSource = listorderbycompany;
                    gvdetailbillbuybycompany.DataBind();
                    gvdetailbillbuybycompany.Visible = true;
                    for (int i = 0; i < listorderbycompany.Count; i++)
                    {
                        TotalPrice += (decimal)listorderbycompany[i].Cost;
                    }
                }
                lbtotalprice.Text = TotalPrice.ToString("###,###,###") + " VND";
            }
        }
    }
}
